package com.itlaoqi.rabbitmq.mirror;

import com.itlaoqi.rabbitmq.utils.RabbitConstant;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class Producer {
    public static void main(String[] args) throws IOException, TimeoutException {

        Connection conn = RabbitUtils.getConnection();

        //创建通信通道，相当于TCP中的虚拟连接
        Channel channel = conn.createChannel();
        channel.queueDeclare(RabbitConstant.QUEUE_HELLOWORLD,false,false,false,null);
        String message = "helloworld";
        channel.basicPublish("",RabbitConstant.QUEUE_HELLOWORLD,null,message.getBytes());
        channel.close();
        conn.close();
        System.out.printf("数据发送成功");
    }
}









